﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LdapPredlogeSeznam.aspx.cs" Inherits="Sio.Mdm.Web.Instalacija.LdapPredlogeSeznam" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript">

        function renderDateTime(value) {
            return value.format('d.m.Y G:i');
        }

        var LdapOrganizacijeRenderer = function(value) {            
            var r = StoreOrganizacije.getById(value);
            if (Ext.isEmpty(r)) { return "NA"; }
            return r.data.Naziv;
        };

        function setButtons() {            
            btnRemove.setDisabled(false);            
        }
        
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    <ext:Store ID="StoreOrganizacije" runat="server">
	<Reader>
		<ext:JsonReader IDProperty="OrganizacijaId">
			<Fields>
				<ext:RecordField Name="OrganizacijaId" Type="Int" />
				<ext:RecordField Name="Naziv" Type="String" />
			</Fields>
		</ext:JsonReader>
	</Reader>
    </ext:Store>        
    
    <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
    <Content>
        <sio:GridPanel ID="GridPredlogeSeznam" runat="server" StripeRows="true" TrackMouseOver="true" AutoExpandColumn="Opis">                
                <Store>
                    <ext:Store ID="StorePredlogeSeznam" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="LdapPredlogaID">
                                <Fields>
                                    <ext:RecordField Name="LdapPredlogaID" Type="Int" />
                                    <ext:RecordField Name="OrgarnizacijaID" Type="Int" />
                                    <ext:RecordField Name="Ime" Type="String" />
                                    <ext:RecordField Name="Opis" Type="String" />                                    
                                    <ext:RecordField Name="DatumVnosa" Type="Date" /> 
                                    <ext:RecordField Name="Datoteka" Type="String" />                                                                       
                                </Fields>
                            </ext:JsonReader>                            
                        </Reader>                        
                    </ext:Store>
                </Store>
                    <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="LdapPredlogaID" Hidden="true" Hideable="false" DataIndex="LdapPredlogaID" Header="LdapPredlogaID">
                        </ext:Column>
                        <ext:Column ColumnID="OrgarnizacijaID" Hidden="false" Hideable="false" DataIndex="OrgarnizacijaID" Header="Organizacija" Width="150">
                            <Renderer Fn="LdapOrganizacijeRenderer" /> 
                        </ext:Column>                        
                        <ext:Column ColumnID="Ime" Hidden="false" Hideable="false" DataIndex="Ime" Header="Ime" Width="150">
                        </ext:Column>                        
                        <ext:Column ColumnID="Opis" Hidden="false" Hideable="false" DataIndex="Opis" Header="Opis">
                        </ext:Column>
                        <ext:Column ColumnID="Datoteka" Hidden="false" Hideable="false" DataIndex="Datoteka" Header="Datoteka" Width="120">
                        </ext:Column>
                        <ext:Column ColumnID="DatumVnosa" Hidden="false" Hideable="false" DataIndex="DatumVnosa" Header="Datum vnosa">
                            <Renderer Fn="renderDateTime" />
                        </ext:Column>                                                         
                    </Columns>
                </ColumnModel>
                <SelectionModel>                                                            
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
						<Listeners>
							<RowSelect Handler="setButtons();" />
						</Listeners>
					</ext:RowSelectionModel>					
                </SelectionModel>
                <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>                    
                    <sio:Button runat="server" ID="btnEdit" Text="Uredi" Icon="NoteEdit" Disabled="true">                                
                        <Listeners>
                            <Click Handler="PrepareParamsAndShowDialog('Edit',#{GridPredlogeSeznam},#{DialogPredlogePodrobno});" />
                        </Listeners>
                    </sio:Button>
                    <sio:Button runat="server" ID="btnRemove" Text="Odstrani" Icon="Delete" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="OdstraniZapise">
                                <Confirmation ConfirmRequest="true" Message="Odstranim izbrane zapise?" />
                                <ExtraParams>
                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridPredlogeSeznam}.getRowsValues({selectedOnly:true}))" />
                                </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </sio:Button>                    
                    <ext:ToolbarSeparator />
                    <sio:Button runat="server" ID="btnCarovnikPredlog" Text="Nova predloga" Icon="Wand">
                        <Listeners>
                            <Click Handler="#{DialogPredlogeNovo}.show();" />
                        </Listeners>
                    </sio:Button>
                 </Items>
                </ext:Toolbar>
                </TopBar>
         </sio:GridPanel>
    
    </Content>
    </ext:Viewport>
    
    <sio:Dialog runat="server" ID="DialogPredlogeNovo"
		Width="600"
		Height="400"
		Url="LdapPredlogeNovo.aspx"
		DialogButtons="SaveClose"
    Title="Kreiranje nove predloge">
        <Parameters>
			<ext:Parameter Name="StreznikID" Value="0" Mode="Value" />
			<ext:Parameter Name="OrgarnizacijaID" Value="0" Mode="Value" />
		</Parameters>
		<Listeners>
            <Hide Handler="#{StorePredlogeSeznam}.reload();" />
        </Listeners>
	</sio:Dialog>
    </form>
</body>
</html>
